﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuantitativeInvestment.Bean;
using QuantitativeInvestment.Tools;

namespace QuantitativeInvestment.Factor
{
    class AdoscFactor:Factor
    {
        public AdoscFactor()
        {
            this.name = "佳庆指标";
            Parameter p = new Parameter("天数",180);
            this.paraList.Add(p.name,p);

            Parameter p2 = new Parameter("快速期", 30);
            this.paraList.Add(p2.name, p2);

            Parameter p3 = new Parameter("慢速期",90);
            this.paraList.Add(p3.name, p3);
        }
        public override void addFactorValue(Stock stock)
        {
            int num = Int32.Parse(this.paraList["天数"].value.ToString());
            int optInFastPeriod=Int32.Parse(this.paraList["快速期"].value.ToString());
            int optInSlowPeriod = Int32.Parse(this.paraList["快速期"].value.ToString());

            if (!stock.factors.ContainsKey(this.name + this.paraList["慢速期"].value.ToString()))
            {
                TaLib lib = new TaLib();

                double[] adoscValues = lib.getAdosc(stock.factors["最高价"], stock.factors["最底价"], stock.factors["收盘价"], stock.factors["份额"], optInFastPeriod, optInSlowPeriod);
                int length=stock.factors["最高价"].Length;

                stock.factors.Add(this.name + this.paraList["天数"].value.ToString() + "Adosc:", adoscValues);

            }
        }
    }
}
